﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ERPStore.Offers.Repositories
{
	public static class OffersRepositoryExtensions
	{
		public static Models.OfferEx GetOfferByLink(this IQueryable<Models.OfferEx> list, string link)
		{
			return list.SingleOrDefault(i => i.Link.Equals(link, StringComparison.InvariantCultureIgnoreCase));
		}

		public static Models.OfferEx GetOfferByName(this IQueryable<Models.OfferEx> list, string name)
		{
			return list.SingleOrDefault(i => i.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
		}

		public static Models.OfferEx GetOfferById(this IQueryable<Models.OfferEx> list, int offerId)
		{
			return list.SingleOrDefault(i => i.Id == offerId);
		}

		public static Models.OfferedProduct GetOfferedProductById(this IQueryable<Models.OfferedProduct> list, int id)
		{
			return list.SingleOrDefault(i => i.Id == id);
		}

	}
}
